<template>
  <div>
    <form @submit.prevent="fn">
      <label>姓名：</label>
      <input type="text" v-model="form.uname"><br><br>

      <label>年龄：</label>
      <input type="number"  v-model="form.age"><br><br>

      <label>身高：</label>
      <input type="number" step="0.1" v-model="form.height">(米)<br><br>

      <label>体重：</label>
      <input type="number" step="0.1" v-model="form.weight">(公斤)<br><br>

      <label>病史：</label>
      <input type="text"><br><br>

      <button>诊断</button>
    </form>

    <p v-show="flag">患者{{form.uname}}  的诊断结果：{{res}}</p>
  </div>
</template>

<script>
export default {
  data () {
    return {
     flag :false,
      form:{
         uname:'',
         age:'',
         height:'',
         weight:'',
        
      },
     bmi:'',
     res:''
    }
  },
  methods: {
   fn(){
     this.flag =!this.flag
   this.bmi=  this.form.weight/(this.form.height*this.form.height)
     if(this.bmi<18.5){
        this.res='过轻'
     }else if(this.bmi>=18.5 && this.bmi<23.9 ){
          this.res ='正常'
     }else if(this.bmi>=24 && this.bmi<27.9 ){
          this.res ='超重'
     }else {
         this.res ='肥胖'
     }
   }
  }
}
</script>